package kr.hkit.powerjava.chapter11;

class Food {
	protected int calorie;
	protected int price;
	protected int gram;
	
	public Food() {}
	
	public Food(int calorie, int price, int gram) {
		this.calorie = calorie;
		this.price = price;
		this.gram = gram;
	}

	public int getCalorie() {
		return calorie;
	}

	public void setCalorie(int calorie) {
		this.calorie = calorie;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public int getGram() {
		return gram;
	}

	public void setGram(int gram) {
		this.gram = gram;
	}

	@Override
	public String toString() {
		return String.format("Food [calorie=%s, price=%s, gram=%s]", calorie,
				price, gram);
	}
}

class Melon extends Food {
	String farm;

	public Melon(int calorie, int price, int gram, String farm) {
		super(calorie, price, gram);
		this.farm = farm;
	}

	public String getFarm() {
		return farm;
	}

	public void setFarm(String farm) {
		this.farm = farm;
	}

	@Override
	public String toString() {
		return String.format("Melon [farm=%s, calorie=%s, price=%s, gram=%s]",
				farm, calorie, price, gram);
	}
}

public class FoodTest {
	public static void main(String[] args) {
		Food good = new Food(380, 4300, 150);
		Melon green = new Melon(good.calorie, good.price, good.gram, "IT농원");
		
		System.out.println(good);
		System.out.println(green);
	}
}
